package com.effectivcrm;

import groovy.util.logging.Slf4j;

import org.springframework.beans.BeanUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import com.effectivcrm.startup.StartupDataLoadingListener;
@Configuration
@EnableAutoConfiguration(exclude={SecurityConfiguration.class,MvcConfiguration.class,MongoConfiguration.class})
@ComponentScan
@Slf4j
public class Application extends SpringBootServletInitializer {

	public static void main(String[] args) throws Exception {
		SpringApplication application = new SpringApplication(Application.class);
		
		application.addListeners(BeanUtils.instantiate(StartupDataLoadingListener.class));
		application.run(args); 
		
	}
	
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder app) {
		SpringApplication application = app.application();
		application.addListeners(BeanUtils.instantiate(StartupDataLoadingListener.class));
        return app.sources(Application.class);
    }
}
